<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			.box {
				position: absolute;
				top: 100px;
				left: 100px;
				width: 100px;
				height: 100px;
				background-color: orange;
			}
		</style>
	</head>
	<body>
		<div class="box"></div>
		<script src="./js/utils.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			var box = document.getElementsByClassName('box')[0],
				x,
				y;

			box.onmousedown = function(e) {
				var e = e || window.event;

				x = pagePos(e).X - getStyles(box, 'left');
				y = pagePos(e).Y - getStyles(box, 'top');

				document.onmousemove = function(e) {
					var e = e || window.event;

					box.style.left = pagePos(e).X - x + 'px';
					box.style.top = pagePos(e).Y - y + 'px';
				}

				document.onmouseup = function(e) {
					var e = e || window.event;

					this.onmousemove = null;
					this.onmouseup = null;
				}
			}
		</script>
	</body>
</html>
